from .base import UniquePointer


fn take_ptr(owned p: UniquePointer):
    print("take_ptr")
    print(p.ptr)


fn use_ptr(borrowed p: UniquePointer):
    print("use_ptr")
    print(p.ptr)


fn work_with_unique_ptrs():
    let p = UniquePointer(100)
    use_ptr(p)  # Pass to borrowing function.
    take_ptr(p ^)  # Pass ownership of the `p` value to another function.
    # 取消注释，第二次调用，则会收到错误，因为值已传输到函数，因此该值将被销
    # use_ptr(p) # ERROR: p is no longer valid here!
